package com.liuh.fram;

import java.util.concurrent.ExecutorService;

import com.liuh.mail.MailKit;
import com.liuh.mail.MailKit.EmailType;

/**
 * @note 发送邮件
 */
public class SendMail {

	/**
	 * @note 异步发送txt邮件
	 * @author liuh
	 */
	ExecutorService executorService;

	public void synSendTxtMail(final String toEmail, final String emailTopic, final String emailContent) {
		executorService = ThreadManager.getInstance().getExecutorService();
		executorService.submit(new Runnable() {
			public void run() {
				try {
					MailKit.sendMail(toEmail, emailTopic, emailContent, null);
				} catch (Exception e) {
					System.out.println(e.getMessage());
				}
			}
		});
	}

	/**
	 * @note 异步发送html邮件
	 * @author liuh
	 */
	public void synSendHtmlMail(final String toEmail, final String emailTopic, final String emailContent) {
		executorService = ThreadManager.getInstance().getExecutorService();
		executorService.submit(new Runnable() {
			public void run() {
				try {
					MailKit.sendMail(toEmail, emailTopic, emailContent, EmailType.html_email);
				} catch (Exception e) {
					System.out.println(e.getMessage());
				}
			}
		});
	}

	public static void main(String[] args) {
		MailKit.sendMail("278681694@qq.com", "应用错误", "<html><body><h1>你大爷liuhhuil</h1></body></html>", EmailType.html_email);
	}
}
